I am a first year Ph.D. student in Animal Behavior Graduate Group. My reseach questions will play around how human activity affects social behavior in long-tailed macaques (Macaca fascicularis).

I also work with some rhesus macaques (Macaca mulatta) A rhesus monkey stealing shoe

Use the storms data (included in RStudio) to create a plotly graph of the relationship between wind and pressure, where the status of the storm is indicated by a color.

library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.4
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.4.2
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.0.0     ✔ readr   1.1.1
## ✔ tibble  1.4.2     ✔ purrr   0.2.5
## ✔ tidyr   0.8.2     ✔ stringr 1.2.0
## ✔ ggplot2 3.0.0     ✔ forcats 0.3.0
## Warning: package 'ggplot2' was built under R version 3.4.4
## Warning: package 'tibble' was built under R version 3.4.3
## Warning: package 'tidyr' was built under R version 3.4.4
## Warning: package 'purrr' was built under R version 3.4.4
## Warning: package 'forcats' was built under R version 3.4.3
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
ggplotly(
ggplot(data=storms)+
  geom_jitter(aes(x=wind,y=pressure, col = as.character(status)), pch=21, alpha=.05)+
  scale_fill_viridis_c()+
  theme_bw()
)

Create a table that identifies the mean wind, pressure, ts_diameter, hu_diameter of each status of storm (remember to remove NAs!). Use the package htmlTable. Round each mean to only two decimal places (Hint look up the function round)

library(knitr)
storm1<-storms %>% 
  drop_na() %>% 
  group_by(status) %>% 
  summarise(mwind=round(mean(wind),2), mpressure=round(mean(pressure),2), mts_diameter=round(mean(ts_diameter),2), mhu_diameter=round(mean(hu_diameter),2))
## Warning: package 'bindrcpp' was built under R version 3.4.4
  htmlTable::htmlTable(storm1)
status mwind mpressure mts_diameter mhu_diameter
1 hurricane 87.15 966.35 288.11 72.96
2 tropical depression 28.21 1006.47 0 0
3 tropical storm 45.75 999.03 159.61 0.04

CHALLENGE Find the duration, in number of days, of every hurricane from 2010 and later, and then use one of the map functions from purrr to write a sentence saying “Hurricane X lasted Y days” for each of these storms. You can look for some help with these functions here and here.

I can’t figure out by myself… have to look for the answer

hurr_len <- storms %>% 
  filter(status == "hurricane", year >= 2010) %>% 
  group_by(name, year) %>% 
  summarise(num_days = diff(range(day)))

map2_chr(hurr_len$name,hurr_len$num_days, function (x,y) paste("Herricane" ,x,"lasts",y,"days"))
##  [1] "Herricane Alex lasts 29 days"     "Herricane Arthur lasts 2 days"   
##  [3] "Herricane Chris lasts 0 days"     "Herricane Cristobal lasts 3 days"
##  [5] "Herricane Danielle lasts 7 days"  "Herricane Danny lasts 2 days"    
##  [7] "Herricane Edouard lasts 4 days"   "Herricane Ernesto lasts 1 days"  
##  [9] "Herricane Fay lasts 0 days"       "Herricane Fred lasts 30 days"    
## [11] "Herricane Gonzalo lasts 6 days"   "Herricane Gordon lasts 2 days"   
## [13] "Herricane Humberto lasts 2 days"  "Herricane Igor lasts 9 days"     
## [15] "Herricane Ingrid lasts 2 days"    "Herricane Isaac lasts 1 days"    
## [17] "Herricane Joaquin lasts 29 days"  "Herricane Julia lasts 3 days"    
## [19] "Herricane Karl lasts 1 days"      "Herricane Kate lasts 0 days"     
## [21] "Herricane Katia lasts 9 days"     "Herricane Kirk lasts 30 days"    
## [23] "Herricane Leslie lasts 6 days"    "Herricane Lisa lasts 1 days"     
## [25] "Herricane Maria lasts 1 days"     "Herricane Michael lasts 5 days"  
## [27] "Herricane Nadine lasts 29 days"   "Herricane Nate lasts 1 days"     
## [29] "Herricane Ophelia lasts 29 days"  "Herricane Otto lasts 1 days"     
## [31] "Herricane Paula lasts 2 days"     "Herricane Philippe lasts 4 days" 
## [33] "Herricane Rafael lasts 2 days"    "Herricane Richard lasts 1 days"  
## [35] "Herricane Rina lasts 3 days"      "Herricane Sandy lasts 5 days"    
## [37] "Herricane Shary lasts 0 days"     "Herricane Tomas lasts 26 days"